package org.geektimes.rest.test;

import org.geektimes.rest.test.domain.User;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * @FileName: RestTest
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/3/31 - 下午10:51
 */
@Deprecated
public class RestTesting {


    public static void main(String[] args) {
        User user = new User();
        user.setId(5);
        user.setName("张三");
        user.setTitle("没事打李四");
        Entity<Object> entity = Entity.entity(user, MediaType.APPLICATION_JSON_TYPE);
        Client client = ClientBuilder.newClient();
        Response response = client.target("http://127.0.0.1:8080/user")
                .request()
                .post(entity);

        String content = response.readEntity(String.class);
        System.out.println(content);
    }

    // public static void main(String[] args) {
    //     Client client = ClientBuilder.newClient();
    //     Response response = client
    //             .target("http://127.0.0.1:8080/user")      // WebTarget
    //             .request() // Invocation.Builder
    //             .get();                                     //  Response
    //
    //     String content = response.readEntity(String.class);
    //
    //     System.out.println(content);
    //
    // }
}
